<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>P2 Project - GanttMaker: SW2A311_Lib/ProjectCollection.cs Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="client.ico"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">P2 Project - GanttMaker
   &#160;<span id="projectnumber">1.1.0.0</span>
   </div>
   <div id="projectbrief">By student group SW2A311, Aalborg University</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_project_collection_8cs_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Properties</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Events</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">ProjectCollection.cs</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_project_collection_8cs.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;﻿using System;</div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="keyword">using</span> System.Collections;</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="keyword">using</span> System.Collections.Generic;</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="keyword">using</span> System.Collections.ObjectModel;</div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="keyword">using</span> System.IO;</div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="keyword">using</span> System.Linq;</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="keyword">namespace </span>SW2A311_Lib</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;{</div>
<div class="line"><a name="l00013"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html">   13</a></span>&#160;    <span class="keyword">public</span> sealed <span class="keyword">class </span><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html" title="Laves til en singleton, så vi altid kun har én database. ">ProjectCollection</a> : IEnumerable <span class="comment">//http://msdn.microsoft.com/en-us/library/ff650316.aspx</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;    {</div>
<div class="line"><a name="l00015"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#aff1a9dd4989b2908737e0ec37f2ea383">   15</a></span>&#160;        <span class="keyword">private</span> <span class="keyword">static</span> readonly <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html" title="Laves til en singleton, så vi altid kun har én database. ">ProjectCollection</a> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#aff1a9dd4989b2908737e0ec37f2ea383">_instance</a> = <span class="keyword">new</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a1ed31fd914301459a642f4da8d9d1109" title="Privat constructor, så man ikke kommer til at lave flere instancer af ProjectCollection. ">ProjectCollection</a>();  <span class="comment">// Struktur der understøtter singleton ved multithreading.</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a486403ebfe3cf4a9e383c87bf830b03a">   16</a></span>&#160;        <span class="keyword">private</span> <span class="keywordtype">string</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a486403ebfe3cf4a9e383c87bf830b03a">FilePath</a> = AppDomain.CurrentDomain.BaseDirectory + <span class="stringliteral">&quot;\\projects\\&quot;</span>;</div>
<div class="line"><a name="l00017"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">   17</a></span>&#160;        <span class="keyword">private</span> List&lt;ProjectData&gt; <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>;</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;        <span class="keyword">public</span> <span class="keywordtype">int</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a604414fab5a94d016c2fa388ecb79d56">Count</a></div>
<div class="line"><a name="l00019"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a604414fab5a94d016c2fa388ecb79d56">   19</a></span>&#160;        {</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;            <span class="keyword">get</span> { <span class="keywordflow">return</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Count; }</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;            <span class="keyword">private</span> <span class="keyword">set</span> { }</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;        }</div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a1ed31fd914301459a642f4da8d9d1109">   26</a></span>&#160;        <span class="keyword">private</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a1ed31fd914301459a642f4da8d9d1109" title="Privat constructor, så man ikke kommer til at lave flere instancer af ProjectCollection. ">ProjectCollection</a>() { <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a> = <span class="keyword">new</span> List&lt;ProjectData&gt;(); }</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;        <span class="keyword">public</span> <span class="keyword">static</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html" title="Laves til en singleton, så vi altid kun har én database. ">ProjectCollection</a> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a18f7cdac958922dda5bcbf80351285e5">Instance</a></div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a18f7cdac958922dda5bcbf80351285e5">   29</a></span>&#160;        {</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;            <span class="keyword">get</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;            {</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;                <span class="keywordflow">return</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#aff1a9dd4989b2908737e0ec37f2ea383">_instance</a>;</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;            }</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;        }</div>
<div class="line"><a name="l00043"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0677c65be53503572ba4a16f0195b7ca">   43</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0677c65be53503572ba4a16f0195b7ca" title="Add Project metode med minimalt input. ">Add</a>(<span class="keywordtype">string</span> projectName, <span class="keywordtype">string</span> adminName)</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;        {</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;            <span class="keywordflow">if</span> (<a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Exists(x =&gt; x.ProjectName == projectName) || <span class="keywordtype">string</span>.IsNullOrWhiteSpace(projectName))</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;            {</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;                <span class="keywordflow">throw</span> <span class="keyword">new</span> ArgumentException(<span class="stringliteral">&quot;Project name is either invalid or already exists!&quot;</span>);</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;            }</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;            <span class="keywordflow">else</span></div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;            {</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;                <a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> tempProject = <span class="keyword">new</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a>(projectName, adminName);</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;                <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Add(tempProject);</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;            }</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        }</div>
<div class="line"><a name="l00065"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#ae1f163afd567cd4f81dd40f4a96ecb0c">   65</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0677c65be53503572ba4a16f0195b7ca" title="Add Project metode med minimalt input. ">Add</a>(<span class="keywordtype">string</span> projectName, DateTime projectStart, DateTime projectEnd, <span class="keywordtype">string</span> adminName)</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;        {</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;            <span class="keywordflow">if</span> (<a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Exists(x =&gt; x.ProjectName == projectName) || <span class="keywordtype">string</span>.IsNullOrWhiteSpace(projectName))</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;            {</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;                <span class="keywordflow">throw</span> <span class="keyword">new</span> ArgumentException(<span class="stringliteral">&quot;Project name is either invalid or already exists!&quot;</span>);</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;            }</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;            <span class="keywordflow">else</span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;            {</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;                <a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> tempProject = <span class="keyword">new</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a>(projectName, projectStart, projectEnd, adminName);</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;                <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Add(tempProject);</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;            }</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;        }</div>
<div class="line"><a name="l00084"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#aa2c2b0f22b1f245e47d3bdb46afb0d61">   84</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0677c65be53503572ba4a16f0195b7ca" title="Add Project metode med minimalt input. ">Add</a>(<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> projectData)</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;        {</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;            <span class="keywordtype">bool</span> exists = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>.IsNullOrWhiteSpace(projectData.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#a3a7ab00c925cf0f33ca55f65adb7d2e0">ProjectName</a>))</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;            {</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;                <span class="keywordflow">throw</span> <span class="keyword">new</span> ArgumentNullException(<span class="stringliteral">&quot;Project name is invalid!&quot;</span>);</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;            }</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;            <span class="keywordflow">else</span></div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;            {</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;                <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Count; i++)</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;                {</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;                    <span class="keywordflow">if</span> (projectData.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#a3a7ab00c925cf0f33ca55f65adb7d2e0">ProjectName</a> == <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>[i].ProjectName)                <span class="comment">// Check om project eksisterer hvis det gør overskrives det.</span></div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;                    {</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;                        <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>[i] = projectData;</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;                        exists = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;                    }</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;                }</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;                <span class="keywordflow">if</span> (!exists)</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;                {</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;                    <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Add(projectData);                                             <span class="comment">// Hvis project ikke eksisterer tilføjes det.</span></div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;                }</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;            }</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;        }</div>
<div class="line"><a name="l00113"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#ac0742a2cd78d1a75a24e117ea355bc7f">  113</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#ac0742a2cd78d1a75a24e117ea355bc7f" title="Fjerner project hvis det eksisterer og RemoveAll returnerer antal elementer fjernet. ">Remove</a>(<span class="keywordtype">string</span> projectName)</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;        {</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;            <span class="keywordflow">if</span> (<a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.RemoveAll(x =&gt; x.ProjectName == projectName) == 0)</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;            {</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;                <span class="keywordflow">throw</span> <span class="keyword">new</span> ArgumentOutOfRangeException(<span class="stringliteral">&quot;Project does not exist!&quot;</span>);</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;            }</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        }</div>
<div class="line"><a name="l00125"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a2e9c9d62636550a34c44f4b1b9c73420">  125</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a2e9c9d62636550a34c44f4b1b9c73420" title="Finder projektet i databasen og tilføjer Task til det. ">AddTaskToProject</a>(<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> project, <a class="code" href="class_s_w2_a311___lib_1_1_task.html" title="Task-strukturen, der laver opgave elementer til de enkelte projekter. ">Task</a> task)</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;        {</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;            <span class="keywordflow">if</span> (task.<a class="code" href="class_s_w2_a311___lib_1_1_task.html#a6796310900992b9f61da59f995961104">TaskStart</a> &gt;= project.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#acdd115afebdfa5ff6b23ccd36ba0dd9c">ProjectStart</a> &amp;&amp; task.<a class="code" href="class_s_w2_a311___lib_1_1_task.html#ac7a1e6bac726fcd393520ea2f6ae70e9">TaskEnd</a> &lt;= project.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#a268b9c6ad656a4eb5d0643a955727520">ProjectEnd</a>)</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;                <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a080aee3919fb171cd65c4951ebd84999" title="Finder project&#39;et og returnerer det. ">FindProjectByName</a>(project.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#a3a7ab00c925cf0f33ca55f65adb7d2e0">ProjectName</a>).<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#ad739db06b4a615c6c6586fdb86ef3f0a" title="Add Task metode der tager et Task objekt som input. ">AddTask</a>(task);</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;            <span class="keywordflow">else</span></div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;                <span class="keywordflow">throw</span> <span class="keyword">new</span> ArgumentOutOfRangeException(<span class="stringliteral">&quot;Task timespan must be within project range&quot;</span>);</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;        }</div>
<div class="line"><a name="l00138"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#af0c107c4af77e6b23a673806203c6020">  138</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#af0c107c4af77e6b23a673806203c6020" title="Finder projektet i databasen og fjerner Task fra det. ">RemoveTaskFromProject</a>(<span class="keywordtype">string</span> projectName, <a class="code" href="class_s_w2_a311___lib_1_1_task.html" title="Task-strukturen, der laver opgave elementer til de enkelte projekter. ">Task</a> task)</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;        {</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;            <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a080aee3919fb171cd65c4951ebd84999" title="Finder project&#39;et og returnerer det. ">FindProjectByName</a>(projectName).<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#aeb32009e9f511d8b76ddafcb2a10aab5" title="Fjerner project hvis det eksisterer og RemoveAll returnerer antal elementer fjernet. ">DeleteTask</a>(task.<a class="code" href="class_s_w2_a311___lib_1_1_task.html#a6f447459017b126eedbacaa1dfecb67f">TaskName</a>);</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;        }</div>
<div class="line"><a name="l00147"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a1e569adeb53d43bb9cf2ce92fb017e66">  147</a></span>&#160;        <span class="keyword">public</span> ObservableCollection&lt;Task&gt; <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a1e569adeb53d43bb9cf2ce92fb017e66" title="Laver en ObservableCollection med indholdet fra TaskList og returnerer den. ">GetObservableTaskList</a>(<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> project)</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;        {</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">new</span> ObservableCollection&lt;Task&gt;(project.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#a46839430893676fc7d04daf3a8923b53">TaskList</a>);</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;        }</div>
<div class="line"><a name="l00155"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a69e487c230d9420e2fb7e26e5d29cd85">  155</a></span>&#160;        <span class="keyword">public</span> ObservableCollection&lt;ProjectData&gt; <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a69e487c230d9420e2fb7e26e5d29cd85" title="Laver en ObservableCollection med indholdet fra _database og returnerer den. ">GetObservableProjects</a>()</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;        {</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">new</span> ObservableCollection&lt;ProjectData&gt;(<a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>);</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;        }</div>
<div class="line"><a name="l00164"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0649c5324c9b1f158c8ddafe14f27e03">  164</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0649c5324c9b1f158c8ddafe14f27e03" title="Skriver backup af _database til en fil. ">WriteDatabaseToFile</a>(<span class="keywordtype">string</span> filename, <a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> project)</div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;        {</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;            <a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html" title="Klasse med metoderne til at skrive objekter til en fil. ">ObjectToFile</a> serializer = <span class="keyword">new</span> <a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html" title="Klasse med metoderne til at skrive objekter til en fil. ">ObjectToFile</a>();</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;            <span class="keywordflow">if</span> (!Directory.Exists(<a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a486403ebfe3cf4a9e383c87bf830b03a">FilePath</a>))</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;            {</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;                Directory.CreateDirectory(<a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a486403ebfe3cf4a9e383c87bf830b03a">FilePath</a>);</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;            }</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;            <span class="keywordtype">string</span> fullFilePath = <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a486403ebfe3cf4a9e383c87bf830b03a">FilePath</a> + filename + <span class="stringliteral">&quot;.txt&quot;</span>;</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;            serializer.SerializeObject&lt;<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a>&gt;(fullFilePath, project);</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;        }</div>
<div class="line"><a name="l00180"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a6c0106916ee2df101944d3c646e5a081">  180</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a6c0106916ee2df101944d3c646e5a081" title="Indlæser fil med backup og tilføjer det til _database. ">ReadDatabaseFromFile</a>()</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;        {</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;            <a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html" title="Klasse med metoderne til at skrive objekter til en fil. ">ObjectToFile</a> serializer = <span class="keyword">new</span> <a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html" title="Klasse med metoderne til at skrive objekter til en fil. ">ObjectToFile</a>();</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;            <span class="keywordflow">try</span></div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;            {</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;                <span class="keywordflow">if</span> (Directory.Exists(<a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a486403ebfe3cf4a9e383c87bf830b03a">FilePath</a>))</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;                {</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;                    <span class="keywordflow">foreach</span> (<span class="keywordtype">string</span> f <span class="keywordflow">in</span> Directory.EnumerateFiles(<a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a486403ebfe3cf4a9e383c87bf830b03a">FilePath</a>))</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;                        <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Add(serializer.DeSerializeObject&lt;<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a>&gt;(f));</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;                }</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;            }</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;            <span class="keywordflow">catch</span> (FileNotFoundException)</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;            {</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;                <span class="comment">// Hvis filen ikke findes, indlæses intet. </span></div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;            }</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;        }</div>
<div class="line"><a name="l00200"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a94d59b4aed15d2e3ac4497a303458a3e">  200</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">int</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a94d59b4aed15d2e3ac4497a303458a3e" title="Count kaldes på _database og antallet af projekter returneres. ">GetNumberOfElements</a>()</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;        {</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;            <span class="keywordflow">return</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Count;</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;        }</div>
<div class="line"><a name="l00209"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a15ba21ecb4f07eb8ace375610e0d2a60">  209</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">int</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a15ba21ecb4f07eb8ace375610e0d2a60" title="Finder index til specifikt project og returnerer det. ">IndexOf</a>(<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> project)</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;        {</div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;            <span class="keywordtype">int</span> i = 0;</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;            <span class="keywordflow">if</span> (project != null)        <span class="comment">//  Tjek for null reference</span></div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;            {</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;                <span class="keywordflow">foreach</span> (<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> p <span class="keywordflow">in</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>)</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;                {</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;                    <span class="keywordflow">if</span> (p.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#a3a7ab00c925cf0f33ca55f65adb7d2e0">ProjectName</a> == project.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#a3a7ab00c925cf0f33ca55f65adb7d2e0">ProjectName</a>)</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;                        <span class="keywordflow">return</span> i;</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;                    i++;</div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;                }</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;            }</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;            <span class="keywordflow">return</span> -1;                  <span class="comment">// Hvis project ikke eksisterer returneres -1.</span></div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;        }</div>
<div class="line"><a name="l00229"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a426cc5d125e76a34a12922fb4d4dc54a">  229</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">bool</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a426cc5d125e76a34a12922fb4d4dc54a" title="Finder projektet med en bestemt index i _database og returnerer det. Med bool check om projektet blev...">TryItemAtIndex</a>(<span class="keywordtype">int</span> i, out <a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> pd)</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;        {</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;            <span class="keywordflow">if</span> (i &lt; <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Count)</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;            {</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;                pd = <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>[i];</div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;                <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;            }</div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;            <span class="keywordflow">else</span></div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;            {</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;                pd = null;</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;                <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;            }</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;        }</div>
<div class="line"><a name="l00250"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a080aee3919fb171cd65c4951ebd84999">  250</a></span>&#160;        <span class="keyword">public</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a080aee3919fb171cd65c4951ebd84999" title="Finder project&#39;et og returnerer det. ">FindProjectByName</a>(<span class="keywordtype">string</span> projectName)</div>
<div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;        {</div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>.IsNullOrWhiteSpace(projectName))</div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;            {</div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;                <span class="keywordflow">throw</span> <span class="keyword">new</span> ArgumentException(<span class="stringliteral">&quot;That project name is invalid!&quot;</span>);</div>
<div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;            }</div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Exists(x =&gt; x.ProjectName == projectName))</div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;            {</div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;                <a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> projectByName = null;</div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;</div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;                <span class="keywordflow">foreach</span> (<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> p <span class="keywordflow">in</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>)</div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;                {</div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;                    <span class="keywordflow">if</span> (p.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#a3a7ab00c925cf0f33ca55f65adb7d2e0">ProjectName</a> == projectName)</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;                        projectByName = p;</div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;                }</div>
<div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;                <span class="keywordflow">return</span> projectByName;</div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;            }</div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;            <span class="keywordflow">else</span></div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;            {</div>
<div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;                <span class="keywordflow">throw</span> <span class="keyword">new</span> ArgumentException(<span class="stringliteral">&quot;Project does not exist!&quot;</span>);         <span class="comment">// Hvis projectet ikke blev fundet.</span></div>
<div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;            }</div>
<div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;        }</div>
<div class="line"><a name="l00279"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a97efce66ebf16ea7ba616510242f0909">  279</a></span>&#160;        <span class="keyword">public</span> List&lt;ProjectData&gt; <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a97efce66ebf16ea7ba616510242f0909" title="Finder alle projekter der er aktive til dags dato. ">GetActiveProjects</a>()</div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;        {</div>
<div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;            List&lt;ProjectData&gt; activeProjects = <span class="keyword">new</span> List&lt;ProjectData&gt;();</div>
<div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;            DateTime timeNow = DateTime.Now;                <span class="comment">// Henter dato og tid fra windows.</span></div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;            <span class="keywordflow">foreach</span> (<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> p <span class="keywordflow">in</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>)</div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;            {</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;                <span class="keywordflow">if</span> (p.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#acdd115afebdfa5ff6b23ccd36ba0dd9c">ProjectStart</a> &lt; timeNow &amp;&amp; p.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#a268b9c6ad656a4eb5d0643a955727520">ProjectEnd</a> &gt; timeNow)</div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;                {</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;                    activeProjects.Add(p);</div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;                }</div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;            }</div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;            <span class="keywordflow">return</span> activeProjects;</div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;        }</div>
<div class="line"><a name="l00296"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#ac78b41ace5c29f5060c10c9b85d51a77">  296</a></span>&#160;        <span class="keyword">public</span> IEnumerator <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#ac78b41ace5c29f5060c10c9b85d51a77" title="En GetEnumerator så foreach og andre metoder kan få adgang til vores private _database liste...">GetEnumerator</a>()</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;        {</div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;            <span class="keywordflow">return</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.GetEnumerator();</div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;        }</div>
<div class="line"><a name="l00307"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#ad11ea87d861b459120e133610ca2c733">  307</a></span>&#160;        <span class="keyword">public</span> IEnumerable <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#ad11ea87d861b459120e133610ca2c733" title="Collection metode med sortering, der returnerer 1 objekt og husker hvor den er kommet til...">GetEnumeratorSorting</a>()</div>
<div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;        {</div>
<div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;            IEnumerable&lt;ProjectData&gt; tempList = <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>                       <span class="comment">// Laver en IEnumerable collection til en midlertidig liste af vores projekter.</span></div>
<div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;                .OrderByDescending(x =&gt; x.ProjectStart)                         <span class="comment">// Sorterer listen med faldende værdier (ældste project først?).</span></div>
<div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;                .ThenBy(x =&gt; x.ProjectName);                                    <span class="comment">// Derefter sorteres alfabetisk.</span></div>
<div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;            <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>.Count; i++)</div>
<div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;                yield <span class="keywordflow">return</span> tempList.ElementAt(i);                             <span class="comment">// Til sidst returneres 1 værdi og der huskes hvor den er kommet til.</span></div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;        }</div>
<div class="line"><a name="l00319"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a5b786cb02620422364d734c62cced30e">  319</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">override</span> <span class="keywordtype">string</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a5b786cb02620422364d734c62cced30e" title="Override af ToString metoden. ">ToString</a>()</div>
<div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;        {</div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;            <span class="comment">// Override af ToString der skriver alle projekter i _database til en string og returnerer den. Bruges til debugging. </span></div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;            <span class="keywordtype">string</span> projectString = <span class="stringliteral">&quot;&quot;</span>;</div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;            <span class="keywordflow">foreach</span> (<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html" title="Projekt-strukturen, der laver projekt elementer. ">ProjectData</a> p <span class="keywordflow">in</span> <a class="code" href="class_s_w2_a311___lib_1_1_project_collection.html#a0c754a374928fbd5afd8e4acb5eadc09">_database</a>)</div>
<div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;            {</div>
<div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;                projectString = <span class="keywordtype">string</span>.Concat(projectString, <span class="stringliteral">&quot;\n&quot;</span>, p.<a class="code" href="class_s_w2_a311___lib_1_1_project_data.html#aa0306dcea4a08e927c6ab4f960f79f7d" title="Override af ToString metoden. ">ToString</a>());</div>
<div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;            }</div>
<div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;            <span class="keywordflow">return</span> projectString;</div>
<div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;        }</div>
<div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;    }</div>
<div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_15ca01a5c548f04ea2501ecd174c056e.html">SW2A311_Lib</a></li><li class="navelem"><a class="el" href="_project_collection_8cs.html">ProjectCollection.cs</a></li>
    <li class="footer">Generated on Fri May 17 2013 11:47:21 for P2 Project - GanttMaker by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.3.1 </li>
  </ul>
</div>
</body>
</html>
